﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using TraderWeapon;
using LogicProgram;
using WeaponLibrary;
using ProgramInterface;
namespace TraderWeapon
{
    public partial class Trader : Form
    {
        ProductCalculation _calc = new ProductCalculation();
        ProductPrinter _print = new ProductPrinter();
        ProductFactory _fact = new ProductFactory();
        FileLogger _flogger = new FileLogger();
        ConsoleLogger _clogger = new ConsoleLogger();
        List<Weapon> _weapon = new List<Weapon>();
        public Trader()
        {
            InitializeComponent();
            
            textBox1.Text += "Name" + '\t' + '\t' + "Weght" + '\t' + '\t' + "Cost" + Environment.NewLine + "1 - " + "Strike" + '\t' + '\t' + 0.89 + '\t' + '\t' + 2600 + Environment.NewLine + "2 - " + "Chastener" + '\t' + 0.1 + '\t' + '\t' + 1000;
        }

        private void Trader_Load(object sender, EventArgs e)
        {
            
        }

        private void button1_Click(object sender, EventArgs e)
        {
           
            switch (Convert.ToInt64(textBox4.Text))
            {
                case 1:
                    {
                        Weapon.Firearms.Gun _product = _fact.CreateGun();
                        _weapon.Add(_product);
                        textBox3.Text += (_product.Name + " " + _product.Weight + " " + _product.Cost + " " + _product.Calibr + " " + _product.Capacity + " " + _product.Accuracy + " " + _product.Rapidity) + Environment.NewLine; _flogger.Log("Gun was bought"); _clogger.Log("Gun was bought"); break;
                    }
                case 2:
                    {
                        Weapon.Meleeweapons.Dagger _product = _fact.CreateDagger();
                        _weapon.Add(_product);
                      //  textBox3.Text += (_product.Name + " " + _product.Weight + " " + _product.Cost + " " + _product.Length + " " + _product.HandCount + " " + _product.DoubleEdged) +Environment.NewLine; _flogger.Log("Dagger was bought"); _clogger.Log("Dagger was bought"); break;
                    }
            }
            textBox2.Text = _clogger.WriteLog() + Environment.NewLine;
        }

        private void button3_Click(object sender, EventArgs e)
        {
            _flogger.Log("Work was completed"); _clogger.Log("Work was completed");
            textBox2.Text = _clogger.WriteLog() + Environment.NewLine;
            Environment.Exit(0);
        }

        private void button2_Click(object sender, EventArgs e)
        {
            textBox5.Text = Convert.ToString(_calc.GetTotalPrice(_weapon, _weapon.Count)); _flogger.Log("Total price was written"); _clogger.Log("Total price was written");
            textBox2.Text = _clogger.WriteLog() + Environment.NewLine;
        }
    }
}
